<?php

class modulPageEdit extends GetData{

	public $daten;
	protected $User_Id;
	protected $aktionError;

	public function __construct($match){
		$this->daten = $match;		
	}

	public function getWort(RainTPL $design){
		$this->design = $design;
		$user_page_static = new Db_user_page_static();
		parent::GetData();
		
	    if(isset($this->daten['Modul_del_Id'])){
		    $moduldel = new Db_modul();
			if ($moduldel->delModul($this->ActivUser->id,$this->daten['Modul_del_Id'])) {
				HTTP::redirect ( BASE_URL . '/Explorer/156' );
			}else{			    
				HTTP::redirect ( BASE_URL . '/error/156' );
			}
		}
		if(isset($this->daten['ModulId']) && !isset($this->design->post->ntouch_modul_nr)){
		    $modulCheck = new Db_modul();
			if (!$modulCheck->checkIfUserHaveAktiv($this->ActivUser->id,$this->daten['ModulId'])) {
				HTTP::redirect ( BASE_URL . '/fehler/1' );
			}
		}
		
		$crumb = new Crumb($design,2);
		
		$this->design->assign ('bcn', $crumb->getCrumb_Name());
		$this->design->assign ('bcrumb',$crumb->getCrumb());
		
        $this->design->assign('js', "jsStaticPageEdit");
		$this->design->assign('css', "StaticPageEdit");
		
		$navi = $user_page_static->getNavi("Webseiten","Deine Seiten");		
		$this->design->assign ('navi',$navi);
		
		if(isset($this->daten['ModulId'])){		    
	    	$modulclass = $modulCheck->getModulSetting($this->daten['ModulId']);
	    	
	    	include_once 'app/modul/'.$modulclass->Controller.'.php';
	    	
			$modulclass = new $modulclass->Controller($this->design);			    
			$ModulePageSetting = $modulclass->getDbSetting();	

			$ModulPage = new Db_user_page_explorer();			
				 
    	    if(isset($this->daten['ModulId']) && $this->design->post->ntouch_modul){
    		   $ModulPage->updateModul($this->ActivUser->id,$this->design->post->ntouch_pageid,$this->design->post);
    		   $modulclass->updateDbSetting($this->ActivUser->id,$this->design->post->Modul);

    		   HTTP::redirect ( BASE_URL . '/Explorer/526' );
    		}
			
			$page = $ModulPage->getModulPage($this->ActivUser->id,$this->daten['ModulId']);
			
			    
	        $this->design->assign ( 'page',$page);
	        $this->design->assign ( 'modulpage',$ModulePageSetting);
	        
		    if( $cache = $this->design->cache($this->design->ln.'/User/Page/Modul/Edit', $expire_time = 0 ) )
			{
			 	echo $cache;
			}
			else
			{
			 	$this->design->draw($this->design->ln.'/User/Page/Modul/Edit');
			}
	    }
	}

}
?>